#!/usr/bin/env python
# encoding: utf-8
#
# Simple Python script to plot given patterns.
#
# Usage:
#    python plot.py
#
# Requirements:
# - numpy
# - scipy
# - matplotlib
#

import pylab
import numpy
import json

def plotme(filename, idx):
	json_data=open(filename).read()
	data = json.loads(json_data)
	points=data['points']
	arrayX = []
	arrayY = []
	x=points[0]['x']
	y=points[0]['y']
	i=0
	for elem in points:
		x2=elem['x']
		y2=elem['y']
		i+=1
		if x!=x2 or y!=y2: #if (i % 11)==0:#
			arrayX.append(int(x2))
			arrayY.append(int(y2))
			x=x2
			y=y2
			
	ax = pylab.subplot(5,5,idx)
	ax.axis([0, 30,20, 0])
	if idx > 20:
		ax.xaxis.set_ticks([0,30])
	else:
		ax.xaxis.set_ticks([])
	if idx % 5 == 1:
		ax.yaxis.set_ticks([0,20])
	else:
		ax.yaxis.set_ticks([])

	pylab.plot(arrayX,arrayY,'bs')
	

idx = 1
for pat in range(1,6):
	for pati in range(1,6):
		plotme('pattern%d_%d.json' % (pat, pati), idx)
		idx += 1

pylab.show()

